import org.junit.Test;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;

public class JdbcLearn {
    private String user="root";
    private String password="123456";
    private String db="lhcx";
    private Connection connection=null;

    public static void main(String[] args) throws SQLException, IOException, ClassNotFoundException {
    new JdbcLearn();
    }
    public JdbcLearn() throws IOException, ClassNotFoundException, SQLException {
        Properties properties = new Properties();
        properties.load(new FileInputStream("src/jdbc.properties"));
        String user=properties.getProperty("user");
        String password=properties.getProperty("password");
        String url=properties.getProperty("url");
        String driver=properties.getProperty("driver");
        Class.forName(driver);
        connection= DriverManager.getConnection(url,user,password);
        System.out.println("connection = " + connection);
    }
}
